﻿Imports CustomTshirtFinal

Public Class PedidoEditar
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

            Dim id = Request.Params.Get("id")

            Dim negocio = New PedidoNegocio
            Dim modelo = negocio.obtener(id)

            Me.txtIdPedido.Value = modelo.idPedido
            Me.txtIdUsuario.Text = modelo.Usuario_idUsuario
            Me.txtFecha.Text = modelo.fecha
            Me.txtEstado.Text = modelo.estado
            Me.txtTotal.Text = modelo.total

        End If
    End Sub

    Protected Sub btnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click
        Try
            Dim negocio = New PedidoNegocio
            negocio.actualizar(Me.txtIdPedido.Value, Me.txtFecha.Text, Me.txtEstado.Text, Me.txtTotal.Text)

            Response.Redirect("Pedidos.aspx", True)
        Catch ex As Exception
            Response.Write("No se pudo actualizar")
        End Try
    End Sub

    Protected Sub btnRegresar_Click(sender As Object, e As EventArgs) Handles btnRegresar.Click
        Response.Redirect("Pedidos.aspx", True)
    End Sub
End Class